Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: font-stretch doesn't match the regex #56

Merged
merged 1 commit into from
Sep 29, 2021

Conversation

TingyuHuang
Copy link
Contributor

This pull request fix the issue of font-stretch doesn't match the regex (#51) and provides an example5 for demo the issue.

Signed-off-by: Tingyu Huang [email protected]

@sacparker09
Copy link

@TingyuHuang - this is looking good to me, tested with format types, will close PR #55

@sacparker09 sacparker09 mentioned this pull request Sep 24, 2021
@MartB
Copy link

MartB commented Sep 29, 2021

@battlesnake, this needs to be merged, open sans is affected and is a widely used font, leading to build failures with this gulp plugin e.g on bitwarden_web.

Copy link

@MartB MartB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo fix is needed, the rest is up to the author to decide.

"\\s*font-family:\\s*'(?<family>[^']+)';",
"\\s*font-style:\\s*(?<style>\\w+);",
"\\s*font-weight:\\s*(?<weight>\\w+);",
".*(?:\\s*font-stretch:\\s(?<stretch>[^;]+);)?",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the .* really needed?
It would actually be better if this entire "we match everything at once" would go away and we would match the stuff we really need instead.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A proper parser CSS parser might be useful instead of using Regexes here. I'm open to PRs.

Copy link
Contributor Author

@TingyuHuang TingyuHuang Sep 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .* is cpoied from the pattern of unicode-range. It could help when there are lines between font-weight and font-stretch. I agree that a proper CSS parser would be helpful. This PR is a quick fix.


let found = block.match(re, 'm');
if (found === null) {
throw new Error("faild to match block");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo, "faild" => "failed"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. It's fixed in #57 .

@battlesnake battlesnake merged commit 3e89058 into battlesnake:master Sep 29, 2021
@Apollo13a
Copy link

If the issue is fixed, could anyone please update npm package?

@battlesnake
Copy link
Owner

Done, 4.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants